﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;
using System.Windows.Controls;

namespace DocManagerControls.Converters
{
    public class ColumnsTemplateSelector : DataTemplateSelector
    {

        public IList<string> CampiCombo { get; set; }

       public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container)
       {
           DataTemplate dataTemp = null;
           Controls.DynamicControl myControl = null;
           DependencyObject dep = container;

           for (int i = 0; i < 20; i++)
           {
               dep = VisualTreeHelper.GetParent(dep);
               myControl = dep as Controls.DynamicControl;
               if (myControl != null) break;
           }
           
           myControl = myControl as Controls.DynamicControl;
           if (myControl != null)
               dataTemp = myControl.FindResource("ComboTemplate") as DataTemplate;

           return dataTemp;
       }

        

    }//fm
}
